<?php

session_start();

include('includes/config.php');

// Smarty template
$smarty = new Smarty();
$smarty->template_dir = TEMPLATES_PATH;
$smarty->compile_dir = TEMPLATES_C_PATH;
$smarty->config_dir = CONFIGS_PATH;
$smarty->cache_dir = CACHE_PATH;

$smarty->assign('path',$conf['base_path']);
$smarty->assign('title',$title);


if ( isset($_POST['mod']) || isset($_GET['plugin']) ){
	$mod = (isset($_POST['mod']))?$_POST['mod']:$_GET['plugin'];
	if (! isAuth() && $mod != 'auth')
		$smarty->display('login.tpl');
	else {
		$path_modulo = MOD_PATH.'/'.$mod.'.php';
		if ( file_exists($path_modulo) )
			include($path_modulo);
	}
} else {
	if (! isAuth() ){
		$smarty->display('login.tpl');
	} else {
		$smarty->assign('user',$_SESSION['username']);
		$smarty->display('default.tpl');
	}
}

?>
